]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
util: Handle trailing LTR/RTL markers in URLs
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 13 Sep 2019 22:03:02 +0000 (00:03 +0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 16 Sep 2019 20:41:47 +0000 (20:41 +0000)
Some electron apps apparently spread those generously over their
notification text, so may sure to not include them accidentally
in URLs.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1614

js/misc/util.js
tests/unit/url.js

index 87a6c12252892f9905b5b922e9624d25e685884f..db3742eb3dd543668f630f8b5d1b9d60ef734df6 100644 (file)
@@ -14,7 +14,7 @@ var SCROLL_TIME = 100;
 // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
 const _balancedParens = '\\([^\\s()<>]+\\)';
 const _leadingJunk = '[\\s`(\\[{\'\\"<\u00AB\u201C\u2018]';
-const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]';
+const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u200E\u200F\u201C\u201D\u2018\u2019\u202A\u202C]';
 
 const _urlRegexp = new RegExp(
     `(^|${_leadingJunk})` +
index 158316bb41ca1a4b5db077875902d304ca6ee7a4..84aecc95f4180ea8ecb08da2a2636123efebc1e4 100644 (file)
@@ -42,6 +42,8 @@ const tests = [
       output: [ { url: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)', pos: 0 } ] },
     { input: 'https://www.gnome.org/(some_url_with_unbalanced_parenthesis',
       output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
+    { input: 'https://www.gnome.org/‎ plus trailing junk',
+      output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
 
     { input: 'Visit http://www.gnome.org/ and http://developer.gnome.org',
       output: [ { url: 'http://www.gnome.org/', pos: 6 },